/*
 * GMapOverlayServlet.java
 *
 * Created on September 3, 2007, 9:50 PM
 *
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.apps.web.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author demory
 */
public class GMapOverlayServlet extends FPServlet {

  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
    count_++;
    String sessID = request.getSession().getId();
    Logger qlog = getQueryLogger();
    qlog.log(Level.INFO, "GMOS c=" + count_ + " sess=" + sessID + "::doGet entered");

    response.setContentType("text/xml");
    PrintWriter out = response.getWriter();

    //String linkStr = request.getParameter("links");
    int id = new Integer(request.getParameter("id")).intValue();

    try {
      out.println(server_.getGMapOverlayFromID(id));
      qlog.log(Level.INFO, "GMOS c=" + count_ + " sess=" + sessID + "::doGet completed");
    } catch (Exception e) {
      out.println("exception: " + e);
      StackTraceElement stes[] = e.getStackTrace();
      for (int i = 0; i < stes.length; i++) {
        out.println(stes[i]);
      }
    }
  }

  @Override
  public void doPost(HttpServletRequest request,
          HttpServletResponse response)
          throws ServletException, IOException {
    doGet(request, response);
  }

  @Override
  protected String getLoggerCode() {
    return "gmaptrip";
  }
}
